package cn.lyq.card.ui.customer

import android.content.Context
import android.content.Intent
import cn.lyq.card.R
import cn.lyq.card.base.BaseActivity
import cn.lyq.card.data.model.ProblemInfo
import cn.lyq.card.utils.setClick
import kotlinx.android.synthetic.main.act_question_answer.*


class QuestionAnswerActivity : BaseActivity() {

    private val mInfo by lazy {
        intent.getSerializableExtra(KEY_INFO)
            ?.takeIf { it is ProblemInfo }
            ?.run { this as ProblemInfo }
    }

    companion object {
        private const val KEY_INFO = "INFO"

        @JvmStatic
        fun start(context: Context, info: ProblemInfo) {
            val starter = Intent(context, QuestionAnswerActivity::class.java)
                .putExtra(KEY_INFO, info)
            context.startActivity(starter)
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.act_question_answer
    }

    override fun initView() {
        super.initView()
        setMyTitle(R.string.str_question_answer)

        mInfo?.let {
            tvQuestion.text = "问：${it.title}"
            tvAnswer.text = "答：${it.description}"
        }
    }

    override fun initListener() {
        super.initListener()
        tvCallPhone.setClick {
            CustomerSPhoneFg().show(supportFragmentManager, "CustomerSPhoneFg")
        }
    }
}